#include "DataStructure/Input/Element/BeamCoordOptions.h"

#include <iostream>
#include <map>
#include <string>
#include <vector>

#include "DataStructure/Common/Integer.h"

using namespace SG::DataStructure::FEM;

/** @brief 获取梁朝向矢量， 节点1和节点2朝向矢量信息 */
std::vector<BeamCoordOptions> SG::DataStructure::FEM::GetBeamCoordOptions (SG::DataStructure::Common::I64 flag)
{
    std::vector<BeamCoordOptions> flags (3);
    switch (flag)
    {
    case 1:
        flags[0] = OPTION_G;
        flags[1] = OPTION_G;
        flags[2] = OPTION_G;
        return flags;
    case 65:
        flags[0] = OPTION_B;
        flags[1] = OPTION_G;
        flags[2] = OPTION_G;
        return flags;
    case 17:
        flags[0] = OPTION_G;
        flags[1] = OPTION_G;
        flags[2] = OPTION_O;
        return flags;
    case 81:
        flags[0] = OPTION_B;
        flags[1] = OPTION_G;
        flags[2] = OPTION_O;
        return flags;
    case 5:
        flags[0] = OPTION_G;
        flags[1] = OPTION_O;
        flags[2] = OPTION_G;
        return flags;
    case 69:
        flags[0] = OPTION_B;
        flags[1] = OPTION_O;
        flags[2] = OPTION_G;
        return flags;
    case 21:
        flags[0] = OPTION_G;
        flags[1] = OPTION_O;
        flags[2] = OPTION_O;
        return flags;
    case 85:
        flags[0] = OPTION_B;
        flags[1] = OPTION_O;
        flags[2] = OPTION_O;
        return flags;
    default:
        std::cerr << "ERROR FLAG!";
        return flags;
    }
};

SG::DataStructure::Common::I64 SG::DataStructure::FEM::calcFlag (const std::string& flag)
{
    static std::map<std::string, SG::DataStructure::Common::I64> flagMap = {
        { "GGG", 1 }, { "BGG", 65 }, { "GGO", 17 }, { "BGO", 81 }, { "GOG", 5 }, { "BOG", 69 }, { "GOO", 21 }, { "BOO", 85 },
    };

    auto iter = flagMap.find (flag);
    if (iter != flagMap.end ())
    {
        return iter->second;
    }

    // default value "GGG"
    return 1;
}